package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.CompanyDao;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class CompanyImpl implements CompanyDao {
    @Override
    public List<CompanyModel> findAll(CompanyModel companyModel) {
        return null;
    }

    @Override
    public int getCount(CompanyModel companyModel) {
        return 0;
    }

    @Override
    public int add(CompanyModel companyModel) {
        return 0;
    }

    @Override
    public int update(CompanyModel companyModel) {
        return 0;
    }

    @Override
    public int del(CompanyModel companyModel) {
        return 0;
    }

    @Override
    public CompanyModel findById(CompanyModel companyModel) {
        return null;
    }

    @Override
    public CompanyModel getFrontCompanyModel() {
        String sql = "select * from company where is_show=1";
        CompanyModel companyModel = new CompanyModel();
        ResultSet rs = JDBC.getRs(sql);
        try {
            while (rs.next()) {
                companyModel.setLogo(rs.getString("logo"));
                companyModel.setPhone(rs.getString("phone"));
                companyModel.setNet(rs.getString("net"));
                companyModel.setEmail(rs.getString("email"));
                companyModel.setAddress(rs.getString("address"));
                companyModel.setLinePhone(rs.getString("line_phone"));
                companyModel.setVersion(rs.getString("version"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return companyModel;
    }
}
